#include "stdafx.h"

#include "Subject.h"
#include "Observer.h"

using namespace std;

namespace ZeEngine
{
	Subject::Subject()
	{
	}


	Subject::~Subject()
	{
	}

	void Subject::Attach( Observer* pObserver ) const
	{
		m_observers.push_back ( pObserver );
	}

	void Subject::Detach( Observer* pObserver ) const
	{
		m_observers.erase( remove( m_observers.begin(), m_observers.end(), pObserver ) );
	}

	void Subject::Notify() const
	{
		for each ( Observer* pObserver in m_observers )
		{
			if ( pObserver )
			{
				pObserver->Update( this );
			}
		}
	}
}